"""
应用，房子
"""
class Home:

    def __init__(self, area, info, addr):
        """
        构造函数初始化
        """
        self.area = area
        self.info = info
        self.addr = addr
        self.left_area = area
        self.items = []

    def __str__(self):
        """
        重写str方法
        """
        return "房子面子%d，户型%s，房子地址%s，房子可用面积为%d。\n房子中的家具：%s"%(self.area, self.info, self.addr, self.left_area, self.__list_item())

    def __list_item(self):
        """
        私有方法，展示房子家具
        """
        items = ""
        for item in self.items:
           items += item.get_name()
        if len(items) > 0:
            return items
        return "暂时没有家具"

    def add_item(self, item):
        """
        存放一个物品
        """
        self.left_area -= item.get_area()
        self.items.append(item)

class Bed:

    def __init__(self, name, area):
        self.name = name
        self.area = area

    def __str__(self):
        return "%s的面积是%d"%(self.name, self.area)

    def get_area(self):
        return self.area

    def get_name(self):
        return self.name

home = Home(100, "三室一厅", "光谷软件园")
print(home)

bed1 = Bed("席梦思", 4)
home.add_item(bed1)
print(home)

bed1 = Bed("单人床", 2)
home.add_item(bed1)
print(home)